package com.smartfast4j.manager.modules.schedule.task;

import com.smartfast4j.mapper.sys.SysUserMapper;
import com.smartfast4j.pojo.sys.SysUser;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 测试定时任务(演示Demo，可删除)
 * 
 * testTask为spring bean的名称
 *
 */
@Component("testTask")
public class TestTask {
	private Logger logger = LoggerFactory.getLogger(getClass());
	
	@Autowired
	private SysUserMapper sysUserMapper;

	//定时任务只能接受一个参数；如果有多个参数，使用json数据即可
	public void test1(String params){
		logger.info("我是带参数的test方法，正在被执行，参数为：" + params);
		try {
			Thread.sleep(6000L);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		if(StringUtils.isNotEmpty(params)){
			SysUser user = sysUserMapper.selectByPrimaryKey(Long.parseLong(params));
			System.out.println(ToStringBuilder.reflectionToString(user));
		}
	}

	public void test2(){
		logger.info("我是不带参数的test2方法，正在被执行");
	}
}
